const jsdom = require(`jsdom`);
const App = require(`./components/App/App`);
const someData = { what: `eva` };

global.document =new jsdom.JSDOM();
global.window = document.defaultView;

const appDom = App(someData);

const html = `<!DOCTYPE html>
<html>
  <head>
    <title>Know it all</title>
  </head>
  <body>
    ${appDom.outerHTML}
    <script>
      window.SOME_DATA = ${JSON.stringify(someData)};
    </script>
    <script src="app.js"></script>
  </body>
</html>
`;

// a little web server
const express = require(`express`);
const server = express();

server.get(`/`, (req, res) => {
  res.send(html);
});

server.listen(8099); // callbacks are for wimps
console.log('listening *:8099');